<%@ page contentType="text/html;charset=utf-8" errorPage="error.jsp"%>
<%@page import="com.leruan.aasimp.entity.UserTypeEnumEntity"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>注册新用户 - </TITLE>
<LINK href="styles/green/ejforum.css" type=text/css rel=stylesheet>
</HEAD>
<BODY onkeydown="if(event.keyCode==27) return false;" onload="loaded()">
<SCRIPT src="js/common.js" type=text/javascript></SCRIPT>
<SCRIPT src="js/member.js" type=text/javascript></SCRIPT>
<SCRIPT src="js/ajax.js" type=text/javascript></SCRIPT>
<SCRIPT src="js/md5.js" type=text/javascript></SCRIPT>
<DIV class=wrap>
<DIV id=header>
<table>
    <tr>
            <td >
                 <div style="height:73px; width: 193px; background-image: url('images/forumlogo.jpg')"></div>
            </td>
            <td>
                 <div style="height:73px; width: 827px; background-image: url('images/headlogo.jpg')"></div>
            </td>   
    </tr>
</table>
<FORM name="register" onsubmit="return checkfields();" action="register" method="get">
<INPUT type=hidden name=fromPath value="">
<DIV class="mainbox formbox"><SPAN class=headactions><A class=notabs
href="./help/credits_rule.jsp" target=_blank>查看积分策略说明</A> </SPAN> 
<H1>注册</H1>
<TABLE cellSpacing=0 cellPadding=0>
  <THEAD>
  <TR>
    <TH>基本信息 ( * 为必填项)</TH>
    <TD></TD></TR></THEAD>
  <TBODY>
 
  <TR>
    <TH><LABEL for=username>用户名 *</LABEL></TH>
    <TD><INPUT id=username tabIndex=2 maxLength=15 size=25 name="username"><SPAN id=checkuserName>&nbsp;</SPAN></TD>
  </TR>
  <TR>
    <TH><LABEL for=nickname>呢称 *</LABEL></TH>
    <TD><INPUT id=nickname tabIndex=3 maxLength=15 size=25 name=nickname></TD></TR>
  <TR>
    <TH><LABEL for=userType>用户类型 *</LABEL></TH>
    <TD><select id="userType" name="userType">
    <%
    for(UserTypeEnumEntity utee:UserTypeEnumEntity.values()){
    %>
    	<option value="<%=utee.getValue() %>"><%=utee.getDescription() %></option>
    <%
    }
    %>
    </select></TD></TR>
  <TR>
    <TH><LABEL for=pwd1>密码 *</LABEL></TH> 
    <TD><INPUT id=pwd1 tabIndex=4 type=password maxLength=15 size=25 name=pwd1> 
	  <INPUT type=hidden id="password" name="password"> <SPAN id=checkpwd>&nbsp;</SPAN></TD></TR>
  <TR>
    <TH><LABEL for=pwd2>确认密码 *</LABEL></TH>
    <TD><INPUT id=pwd2 onblur=checkpwd2() tabIndex=5 type=password maxLength=15 size=25 name=pwd2><SPAN id=checkpwd2>&nbsp;</SPAN></TD>
 </TR>
  <TR>
    <TH><LABEL for=email>Email *</LABEL></TH> 
    <TD><ul><li><input id="email" onblur="checkemail()" tabindex="6" size="25" maxlength="40" name="email"><span id="checkemail">&nbsp;</span></li></ul></TD>
  </TR>
  <TR>
    <TH>&nbsp;</TH>
    <TD><INPUT class=checkbox id=advshow onclick=showadv() tabIndex=12 
      type=checkbox value=1 name=advshow> 显示扩展信息</TD></TR></TBODY></TABLE>
<TABLE id=adv style="DISPLAY: none" cellSpacing=0 cellPadding=0>
  <THEAD>
  <TR>
    <TH>扩展信息</TH>
    <TD>&nbsp;</TD></TR></THEAD>
  <TBODY>
  <TR>
    <TH>性别</TH>
    <TD><INPUT tabIndex=17 type=radio value=M name="sex"> 男&nbsp; 
      <INPUT tabIndex=18 type=radio value=F name="sex"> 女&nbsp; 
      <INPUT tabIndex=19 type=radio CHECKED value=U name="sex"> 保密 </TD></TR>
  <TR>
    <TH><LABEL for=birthday>生日</LABEL></TH>
    <TD><INPUT id=birthday tabIndex=20 size=25 maxLength=10 value=1970-01-01 name=birthday>
		(&nbsp;格式为 yyyy-mm-dd , 年-月-日&nbsp;)
	</TD></TR>
  <TR>
    <TH vAlign=top><LABEL for=selfIntroduction>自我介绍&nbsp;/&nbsp;个性签名</LABEL></TH> 
    <TD><TEXTAREA id="selfIntroduction" tabIndex=28 name="selfIntroduction" rows=5 cols=40 maxLength=200></TEXTAREA></TD></TR>
  <TR>
    <TH></TH>
    <TD><INPUT tabIndex=42 type=checkbox value="1" name="isShowEmail"> 
      Email 地址可见</TD></TR>
</TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0>
  <TBODY>
  <TR class="btns">
    <TH><LABEL>注册条款</LABEL></TH>
    <TD>
	<INPUT class=checkbox id=protocol tabIndex=99 type=checkbox value='T' onclick="agreerule()" 
 	 name=protocol>&nbsp;我已仔细阅读并接受&nbsp;&raquo;&nbsp;<a href="./help/protocol.jsp" target="_blank">论坛用户守则</a>
	  </TD></TR>
  <TR>
    <TH>&nbsp;</TH>
    <TD height="30">
	<BUTTON class=submit tabIndex=100 name=regsubmit type=submit disabled id=regsubmit style="color:gray">提交</BUTTON>
    </TD></TR></TBODY></TABLE></DIV></FORM>
<SCRIPT type=text/javascript>
var verifycode_invalid = '验证码输入错误，请重新填写';
var passwd_dismatch = '两次输入的密码不一致，请检查后重试';
var lastuserID = lastpwd = lastemail = '';

$('username').focus();

function checkfields() 
{
	if (trim($('username').value) == '')
	{
		warning($('checkuserName'), '请输入用户名');
		return false;
	}
	var tmpStr = trim($('username').value);
	if (tmpStr.indexOf('=') >= 0 || tmpStr.indexOf('*') >= 0 || tmpStr.indexOf('\\') >= 0 
		|| tmpStr.indexOf('&') >= 0 || tmpStr.indexOf('>') >= 0 || tmpStr.indexOf('<') >= 0
		|| tmpStr.indexOf(',') >= 0 || tmpStr.indexOf('\'') >= 0 || tmpStr.indexOf('"') >= 0)
	{
		warning($('checkuserName'), '对不起，用户名中不能包含如下字符：= * & < > , \" \' \\');
		return false;
	}
	if (trim($('pwd1').value) == '')
	{
		warning($('checkpwd'), '请输入密码');
		return false;
	}
	if (trim($('pwd2').value) == '')
	{
		warning($('checkpwd2'), '请再次输入密码');
		return false;
	}
	if (!checkpwd2())
	{
		return false;
	}
	if (trim($('email').value) == '')
	{
		warning($('checkemail'), '请输入您的 Email');
		return false;
	}
	$('password').value = hex_md5(trim($('pwd1').value)); 
	$('pwd1').value = '';
	register.regsubmit.disabled = true;
}

function checkemail() {
	var email = trim($('email').value);
	if(email == lastemail) {
		return;
	} else {
		lastemail = email;
	}
	if(!isLegalEmail(email)) {
		var ce = $('checkemail');
		warning(ce, 'Email 地址无效，请重新填写');
		return;
	}
	ajaxcheck('checkemail', 'act=checkemail&mail=' + 
			 (is_ie && document.charset == 'utf-8' ? encodeURIComponent(email) : email));		
}
function ajaxcheck(objId, data) {
   	var x = new Ajax();
   	x.get('ajax?' + data, function(s){
   	        var obj = $(objId);
   	        if(s == 'OK') {
     	        obj.style.display = '';
       	        obj.innerHTML = '&nbsp;';
        		obj.className = "passed";
       		} else {
       			warning(obj, s);
       		}
   	});
}
function showadv() {
	if(document.register.advshow.checked == true) {
		$("adv").style.display = "";
	} else {
		$("adv").style.display = "none";
	}
}
function agreerule() {
	if(document.register.protocol.checked == true) {
		$("regsubmit").disabled = false;
		$("regsubmit").style.color = "#090";
	} else {
		$("regsubmit").disabled = true;
		$("regsubmit").style.color = "gray";
	}
}
function loaded() {
	agreerule();
}	
</SCRIPT>
</DIV>
</BODY></HTML>
